package game.breeze.gameserver.job;

import game.breeze.gameserver.controller.PlayerController;
import game.breeze.gameserver.message.processor.SceneMessageProcessor;
import game.breeze.gameserver.message.processor.WorldMessageProcessor;
import game.breeze.message.AppMessage;
import game.breeze.socket.connection.NetConnection;
import game.breeze.socket.util.NetJob;

public class ClientMessageJob extends NetJob {
	private AppMessage message;
	private NetConnection conn;

	public ClientMessageJob(NetConnection conn, AppMessage msg) {
		this.message = msg;
		this.conn = conn;
	}

	@Override
	public NetConnection getConn() {
		return null;
	}

	@Override
	public void run() {
		try {
			processClientMessage(conn, message);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			message.clearTransient();
		}
	}

	int i = 0;

	/**
	 * 数据分发
	 * 
	 * @param conn
	 * @param appMessage
	 */
	private void processClientMessage(NetConnection conn, AppMessage msg) {
		switch (msg.getType()) {
		case AppMessage.MSG_FIGHT: // 战斗
			break;
		case AppMessage.MSG_SCENE: // 地图内操作
			SceneMessageProcessor.getInstance().proccessMessage((PlayerController) conn.getAttachment(), msg);
			break;
		case AppMessage.MSG_WORLD:// 世界操作
			WorldMessageProcessor.getInstance().proccessMessage((PlayerController) conn.getAttachment(), msg);
			break;
		case AppMessage.MSG_CHAT:// 聊天
			break;
		case AppMessage.MSG_SHOP:// 商店
			break;
		case AppMessage.MSG_PLAYER:// 个人操作
			break;
		case AppMessage.MSG_PET:// 宠物操作
			break;
		case AppMessage.MSG_TEAM:// 队伍操作
			break;
		case AppMessage.MSG_TRADE:
			break;
		case AppMessage.MSG_SNS:// 社交组织
			break;
		case AppMessage.MSG_TASK:// 任务
			break;
		case AppMessage.MSG_CAMPAIGN://
			break;
		default:
			break;
		}
	}
}
